/* poporca5.p - PURCHASE ORDER RECEIPT W/ SERIAL NUMBER CONTROL               */
/* Copyright 1986 QAD Inc. All rights reserved.                               */
/* $Id:: poporca5.p 85597 2019-04-10 05:45:21Z sm4                         $: */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 02/14/96   BY: jym *G1M9*                */
/* REVISION: 7.3      LAST MODIFIED: 08/21/96   BY: *G1QH* Aruna P.Patil      */
/* REVISION: 9.0      LAST MODIFIED: 04/16/99   BY: *J2DG* Reetu Kappor       */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00   BY: *N0KQ* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.9  BY: Jean Miller DATE: 05/14/02 ECO: *P05V* */
/* Revision: 1.11      BY: Paul Donnelly (SB) DATE: 06/28/03 ECO: *Q00J* */
/* $Revision: 1.12 $     BY: Ellen Borden     DATE: 12/06/05  ECO: *R000*  */
/*-Revision end---------------------------------------------------------------*/
 
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
 
/*!
poporca5.p - PICK UP THE CURRENTLY EFFECTIVE CUM ORDER - FOR NEW REPETITIVE
             CALLED BY poporca.p & porvisa.p rsshmtb.p rsporc.p
*/
 
{us/bbi/mfdeclre.i}
 
define input parameter podnbr       as character no-undo.
define input parameter podline      as integer   no-undo.
define input parameter eff_date     as date      no-undo.
 
define variable wolot   as character no-undo.
define variable msg-arg as character format "x(16)" no-undo.
 
find pod_det  where pod_det.pod_domain = global_domain and  pod_nbr = podnbr
   and pod_line = podline
exclusive-lock.
 
if pod_type <> "s" or pod_wo_lot = "" then leave.
 
for first wo_mstr
   where wo_mstr.wo_domain = global_domain and  wo_lot = pod_wo_lot
no-lock:
end.
 
if not available wo_mstr then leave.
 
/*BLANK INDICATES NEW REPET*/
if wo_type <> "c" or wo_nbr <> "" then leave.
 
if wo_status <> "R" or wo_due_date < eff_date
   or (wo_status = "R" and wo_due_date > eff_date) 
then do:
 
   {us/bbi/gprun.i ""regetwo.p""
      "(input wo_site, input wo_part, input eff_date,
        input wo_line, input wo_routing, input wo_bom_code, output wolot)"}
 
   /* RE-INSTALL CODE COMMENTED OUT BY G1M9.  IT WILL BE RUN IF   */
   /* DATE SPECIFIED                                              */
   if wolot <> ? then do:
 
      for first wo_mstr
         where wo_mstr.wo_domain = global_domain and  wo_lot = wolot
      no-lock:
      end.
 
      if available wo_mstr and wo_status <> "R" then
         wolot = ?.
 
   end.
 
   if wolot = ? then do:
      {us/bbi/gprun.i ""recrtwo.p""
         "(input wo_site, input wo_part,
           input eff_date, input wo_line,
           input wo_routing, input wo_bom_code,
           output wolot)"}
   end.
 
   /* STATEMENT IF WO_MSTR NOT AVAILABLE THEN LEAVE.  WOLOT WILL     */
   /* ONLY BE A ? IF THE WO_MSTR IS NOT AVAILABLE, THEREFOR BEGIN    */
 
   if wolot <> ? then
      pod_wo_lot = wolot.
   else
      pod_wo_lot = " ".
 
end.
 
for first wr_route
   where wr_route.wr_domain = global_domain and  wr_lot = pod_wo_lot
   and   wr_op  = pod_op
no-lock:
end.
 
if not available wr_route then do:
   /* Work Order operation does not exist */
   {us/bbi/pxmsg.i &MSGNUM=511 &ERRORLEVEL=2}
end.
